<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../css/common.css" />
	<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
  <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
  <title>学术</title>
  <style>
		html, body {width: 100%;min-height: 100%;background: #f0f0f0;}
    .h20 {height: 0.5rem;background: #f0f0f0;}
    .xsTab .aui-tab-item {
      border: none;
      position: relative;
    }
    .xsTab .aui-tab-item:after {
      content: '';
      display: block;
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      width: 50%;
      height: 2px;
      background: #fff;
      margin: auto;
    }
    .xsTab .aui-tab-item.aui-active {
      color: #2997e4;
    }
    .xsTab .aui-tab-item.aui-active:after {
      background: #2997e4;
    }
    .xsContent > div {
      display: none;
    }
    .xsContent .aui-list-item-title {
      color: #333;
      line-height: 1.2rem;
      font-size: 0.8rem;
    }
    .xsContent .aui-info-item {
      color: #999;
      font-size: 0.7rem;
    }
    .xsContent .aui-list-item-media {
      width: 6.5rem;
    }
    .aui-media-list .aui-list-item-inner {
			display: -webkit-box;
			display: -webkit-flex;
			display: flex;
			-webkit-box-orient: vertical;
			box-orient: vertical;
			-webkit-flex-direction: column;
			flex-direction: column;
			-webkit-box-pack: justify;
			-webkit-justify-content: space-between;
			justify-content: space-between;
			-webkit-box-align: start;
			-webkit-align-items: flex-start;
			align-items: flex-start;
		}
    .xsContent .aui-list-item .aui-list-item-title {
      color: #333;
      line-height: 1.2rem;
      font-size: 0.8rem;
    }
    .xsContent .aui-list-item .aui-info-item {
      color: #999;
      font-size: 0.7rem;
    }
    .xsContent {
      min-height: calc(100vh - 65px);
    }
    .itemIco {
      width: 100%;
      height: 4rem;
    }

	</style>
</head>
<body>
<section class="aui-refresh-content">
<div class="aui-content aui-margin-b-15 xsContent" id="app" v-cloak>
  <ul class="aui-list aui-media-list">
    <li class="aui-list-item" @click="openShenb(item.newsId)" v-for="item in newsList">
      <div class="aui-media-list-item-inner">
        <div class="aui-list-item-media">
          <!-- <img :src="item.images"> -->
          <div v-if="item.pics" class="itemIco" :style="'background: url('+ item.pics +') center/cover no-repeat'"></div>
          <div v-else class="itemIco" style="background: url(../../image/firstpage/t2@3x.png) center/cover no-repeat"></div>
        </div>
        <div class="aui-list-item-inner">
          <div class="aui-list-item-text">
            <div class="aui-list-item-title">{{item.title}}</div>
          </div>
          <div class="aui-info aui-margin-t-5" style="padding:0">
            <div class="aui-info-item">{{item.createTime}}</div>
          </div>
        </div>
      </div>
    </li>
  </ul>
</div>
</section>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script src="../../script/aui-pull-refresh.js"></script>
<script>
apiready = function() {

  var app = new Vue({
    el: '#app',
    data: {
      newsList: [],
		  page: 1,
      totalpage: 1
    },
    created: function() {
      var $_this = this;
      api.ajax({
        url: window.Url.getArticleList + '1/' + $_this.page,
        timeout: 300,
      }, function(ret, err) {
          if (ret) {
              // api.alert({ msg: JSON.stringify(ret) });
              if (ret.data == null) return
              $_this.newsList = ret.data.newsList
          } else {
              api.alert({ msg: JSON.stringify(err) });
          }
      })
      var scroll = new auiScroll({
            listen:true, //是否监听滚动高度，开启后将实时返回滚动高度
            distance:40 //判断到达底部的距离，isToBottom为true
        },function(ret){
           if (ret.isToBottom) {
             $_this.page ++
             if ($_this.page > $_this.totalpage) {
               $_this.page = $_this.totalpage
               return
             }
             api.ajax({
               url: window.Url.getArticleList + '3/' + $_this.page,
     					timeout: 300,
     				}, function(ret, err) {
     				    if (ret) {
     				       //  api.alert({ msg: JSON.stringify(ret) });
     								$_this.newsList = $_this.newsList.concat(ret.data.newsList)

     				    } else {
     				        api.alert({ msg: JSON.stringify(err) });
     				    }
     				})
           }

        });

        var pullRefresh = new auiPullToRefresh({
            container: document.querySelector('.aui-refresh-content'),
            triggerDistance: 100
        },function(ret){
            if(ret.status=="success"){
              $_this.page = 1;
              api.ajax({
                url: window.Url.getArticleList + '1/' + $_this.page,
                timeout: 300,
              }, function(ret, err) {
                  if (ret) {
                      // api.alert({ msg: JSON.stringify(ret) });
                      setTimeout(function() {
                      if (ret.data == null) {
                        pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                        return;
                      }
                      $_this.newsList = ret.data.newsList
                        pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                      },500)
                  } else {
                      api.alert({ msg: JSON.stringify(err) });
                  }
              })
            }
        })
    },
    methods: {
      openShenb: function (id) {
        api.openWin({
          name: 'index_detail_shenb',
          pageParam: {
            name: 'index_detail_shenb',
            title: '详情',
            id: id
          },
          url: './index_detail_shenb.html',
          delay: 200,
          bounces: false
        });
      }
    }
  })
}

</script>
</html>
